home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT9 / DSERV7.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  23.6 KB  |  562 lines

  1. ;********************************************************************
  2. ;
  3. ;  Program DServ ( Chapter 9 )  
  4. ;
  5. ;  System for treatment of disks written under any operating system.
  6. ;
  7. ;  Author  A.I.Sopin, Voronezh, 1990 --- 1991, Version 1.2
  8. ;
  9. ;  Program for reading-modifying a sector of hard disk
  10. ;
  11. ;  Using:  DSERV7                          
  12. ;
  13. ;  Interrupt used:  INT  25h and 26h (DOS)
  14. ;
  15. ;  Information is shown in the screen (two pages, each of 256 bytes) 
  16.  
  17. ;********************************************************************
  18. NAME     DSERV7
  19. EXTRN    DIAM00 : FAR, DIAM01 : FAR, CLEAR : FAR, DELAY : FAR, COLOR : FAR
  20. EXTRN    MOVE : FAR, HEXSYM : FAR, SYMIN4 : FAR, INSYM4 : FAR, SYMHEX : FAR
  21. ;
  22. ;  Save registers used
  23. PUSHR   MACRO   REGLST
  24.     IFB     <REGLST>
  25.     push    ax
  26.     push    bx
  27.     push    cx
  28.     push    dx
  29.     push    si
  30.     push    di
  31.     push    ds
  32.     push    es
  33.     push    bp
  34.     ENDIF
  35.     IRP     REG,<REGLST>
  36.     push    REG
  37.     ENDM
  38.     ENDM
  39. ;  Restore register used
  40. POPR    MACRO   REGLST
  41.     IFB     <REGLST>
  42.     pop     bp
  43.     pop     es
  44.     pop     ds
  45.     pop     di
  46.     pop     si
  47.     pop     dx
  48.     pop     cx
  49.     pop     bx
  50.     pop     ax
  51.     ENDIF
  52.     IRP     REG,<REGLST>
  53.     pop     REG
  54.     ENDM
  55.     ENDM
  56. ;  Call the procedure for the screen clearing and the color setting
  57. CLR     MACRO  M$,N$,C$
  58.     mov    ch,M$
  59.     mov    dh,N$
  60.     mov    ah,C$
  61.     Call   Color
  62.     ENDM
  63. ;
  64. DIAM0   MACRO   TEXT$,OP$,M$,N$,U$,V$
  65.     mov     TOFF,offset TEXT$    ; address of the string
  66.     mov     OP,OP$               ; work mode
  67.     mov     M,M$                 ; first line for output
  68.     mov     bx,N$                ;
  69.     mov     N,bx                 ; last string for output
  70.     mov     bx,U$                ;
  71.     mov     U,bx                 ;
  72.     mov     bx,V$                ;
  73.     mov     V,bx                 ;
  74.     lea     bx,PARM              ;
  75.     push    bx                   ;  address of parameters vector for DIAM
  76.     Call    DIAM00               ;
  77.     ENDM
  78. ;
  79. DIAM1   MACRO   TEXT$,OP$,M$,N$,U$,V$   
  80.     mov     TOFF,offset TEXT$    ;  the text string address
  81.     mov     OP,OP$               ;  working mode
  82.     mov     M,M$                 ;  first string for output
  83.     mov     bx,N$                ;
  84.     mov     N,bx                 ;  last string for output
  85.     mov     bx,U$                ;
  86.     mov     U,bx                 ;
  87.     mov     bx,V$                ;
  88.     mov     V,bx                 ;
  89.     lea     bx,PARM              ;
  90.     push    bx                   ;  sector address for output by DIAM00
  91.     Call    DIAM01               ;
  92.     ENDM
  93. ;
  94. ;  Preliminary clearing of output buffer (passing blanks)
  95. SPACE   MACRO   TXT$,L$
  96.     mov     ax,ds
  97.     mov     es,ax
  98.     lea     di,TXT$
  99.     mov     cx,L$
  100.     cld
  101.     mov     al,' '
  102.     rep     stosb
  103.     ENDM
  104. ; Output a number in hexadecimal form
  105. HEX     MACRO   L$                       ;
  106.     Local   H1                       ;
  107.     mov     cx,L$                    ;  number of bytes
  108. H1:     mov     al,[si]                  ;
  109.     Call    HEXSYM                   ;  converting HEX to SYM
  110.     mov     DS:[di],ax               ;
  111.     add     di,2                     ;
  112.     inc     si                       ;
  113.     loop    H1                       ;
  114.     ENDM
  115. ;----------------------------------------------------------
  116. STAC     SEGMENT STACK
  117.      db      256 dup (?)
  118. STAC     ENDS
  119. ;----------------------------------------------------------
  120. DATA     SEGMENT
  121. TEXT0    db  ' Disk  X  is not found !!!   (Repeat input) ',0
  122. TEXT2    db  ' Reading-modifying a sector of hard disk.     '
  123.      db  ' A.I.Sopin, Voronezh, 1992 ',0
  124. TEXT3    db  ' Disk drive= C',0
  125. Ltext3   EQU $-TEXT3-2  
  126. TEXT5    db  ' Sector= 00000',0
  127. Ltext5   EQU $-TEXT5-2
  128. ;
  129. TEXT6    db  ' Error while reading the sector !  AH='
  130. TEXT6AX  db  'xx  SEC='
  131. TEXT6SEC db  'xxxxx   (Press ENTER)             ',0
  132. TEXT7    db  ' Error while inputting sector address (repeat input)     ',0
  133. TEXT8    db  ' Error while writing sector!  AH='
  134. TEXT8AX  db  'xx  SEC='
  135. TEXT8SEC db  'xxxxx   (Press ENTER)                    ',0
  136. ;
  137. I2       DB     80,0             ;  length =80, offset =0
  138.      DB     0,74h            ;  background -grey, characters -red
  139.      DW     0
  140. ;
  141. TXT0     db  'Displacement ----------------- Hex codes -------------------'
  142.      db  '     ASCII value    ',0
  143. TXT25    db  ' PgDn -forward, PgUp -back, Esc -exit, F3  -edit, F1 '
  144.      db  '-change panel        '
  145. Ltxt25   EQU $-TXT25
  146. I25      DB     80,0              ;  length =80, offset =0
  147.      DB     0,1Eh             ;  background -grey, characters -red
  148.      DW     0                 ;  end of vector  I
  149. ;
  150. Disp1    db  '0000(0000)','0016(0010)','0032(0020)','0048(0030)'
  151.      db  '0064(0040)','0080(0050)','0096(0060)','0112(0070)'
  152.      db  '0128(0080)','0144(0090)','0160(00A0)','0176(00B0)'
  153.      db  '0192(00C0)','0208(00D0)','0224(00E0)','0240(00F0)'
  154. Disp2    db  '0256(0100)','0272(0110)','0288(0120)','0304(0130)'
  155.      db  '0320(0140)','0336(0150)','0352(0160)','0368(0170)'
  156.      db  '0384(0180)','0400(0190)','0416(01A0)','0432(01B0)'
  157.      db  '0448(01C0)','0464(01D0)','0480(01E0)','0496(01F0)'
  158. ;
  159. BUFER    db     2000 dup (0)            ;
  160. RDBUF    db     512  dup (0)            ;
  161. ADRBUF   dw     0                       ;
  162. ;  Parameter list for sector reading (disk >32M)
  163. TRPACK   LABEL  DWORD                   ;
  164. SECNUM   DD     0                       ;  logical sector number
  165. NUMSEC   DW     1                       ;  number of sectors to be read
  166. ADDRA    DD     RDBUF                   ;  address of reading buffer
  167. SEC      DW     0                       ;  sector number  (0...65535)
  168. ;
  169. VER      DW     0                       ;  AL -version, AH -subversion
  170. Disk     db     0                       ;  drive address (0-A, 1-B...)
  171. NCC0     DW     0                       ;  max cylynder number (0 ...)
  172. NHH0     DB     0                       ;  max head number   (0 ...)
  173. NSS0     DB     0                       ;  max sector number  (1 ...)
  174. VV       dw     0                       ;  cursor setting position: CCHHSS
  175. NN       dw     0                       ;  first output line =6 (disk address)
  176. MOD0     DB     0                       ;  modification sign  CCHHSS
  177. REG      DB     0                       ;  current video mode
  178. DISK0    DB     0                       ;  current disk drive
  179. ;
  180. ;  List of parameters for procedures   DIAM00, DIAM01
  181.      EVEN
  182. PARM     LABEL  WORD                    ; parameter vector (address in stack)
  183. OP       dw     0                       ; operation code
  184. M        dw     0                       ; number of starting row
  185. N        dw     0                       ; number of final row
  186. TOFF     dw     0                       ; offset of string
  187. L        dw     80                      ; length of text string
  188. U        dw     0                       ; row for cursor positioning (1-25)
  189. V        dw     0                       ; column for cursor positioning (1-80)
  190. Q        dw     0                       ; accepted row of cursor
  191. S        dw     0                       ; accepted column of cursor
  192. W        dw  2 dup (0)                  ; code of interrupt key
  193. IOFF     dw     0                       ;  screen format vector address (or 0)
  194. I        dw     80
  195.      db     0, 07h
  196. DATA     ENDS
  197. ;----------------------------------------------------------
  198. CODE    SEGMENT 'CODE'
  199.     ASSUME CS:CODE,DS:DATA,SS:STAC
  200. Start:  mov     ax,DATA                 ;  address of data segment into AX
  201.     mov     ds,ax                   ;
  202.     mov     ah,30h                  ;  read the MS-DOS version
  203.     int     21h                     ;
  204.     mov     VER,ax                  ;  AL - version, AH - subversion
  205.     mov     ah,0Fh                  ;
  206.     int     10h                     ;  read display mode
  207.     mov     REG,al                  ;  save display mode
  208.     mov     IOFF,0                  ;  format vector is not used
  209.     CLR     1,25,07h                ;
  210.     mov     ah,19h                  ;  determine the current drive
  211.     int     21h                     ;  DOS service call
  212.     mov     DISK0,al                ;  store the current drive number
  213. ;  Output the headline and get the disk drive (rows  2---4)
  214. Addres: DIAM0   TEXT2,1,2,2,0,0         ;
  215.     DIAM0   TEXT3,3,4,-4,4,14       ;
  216.     and     TEXT3+Ltext3,0DFh       ;  force CapsLock
  217.     cmp     byte ptr W,1bh          ;  is ESC pressed
  218.     jne     LogDisk                 ;
  219.     jmp     Exit                    ;
  220. ;  Set the logical disk drive
  221. LogDisk:DIAM0   TEXT3,1,4,-4,4,Ltext3+1 ;
  222.     mov     dl,TEXT3+Ltext3         ;
  223.     sub     dl,41h                  ;  0 -A, 1 -B, 2 -C,...
  224.     mov     Disk,dl                 ;  save disk number
  225.     mov     ah,0Eh                  ;  function 0Eh - set default drive
  226. ;----------------------------------------------------------
  227. ;  Request and input of logical sector number  SEC
  228. Diskadr:DIAM0   TEXT5,3,5,-5,5,10       ;
  229.     cmp     byte ptr W+1,49h        ;  PgUp ?
  230.     je      JmpAdr                  ;  return to preceeding parameter
  231.     cmp     byte ptr W,1bh          ;  Esc ?
  232.     jne     ConvSEC                 ;
  233. JmpAdr: jmp     Addres                  ;
  234. ;  Converting the sector address  SEC
  235. ConvSEC:lea     bp,TEXT5+Ltext5-4
  236.     mov     si,5                    ;  source characters counter
  237.     Call    SYMIN4                  ;  convertion string to integer
  238.     mov     SEC,ax                  ;
  239.     jnc     Rdsect                  ;
  240.     DIAM0   TEXT7,1,6,-6,0,0        ;  output error message
  241.     jmp     Diskadr                 ;  repeat input
  242. ;----------------------------------------------------------
  243. ;  Read a sector (512 bytes) at the address requested
  244. Rdsect: Call    SECTOR                  ;  read sector requested
  245.     jnc     Str25                   ;  sector has been read succesfully
  246.     Call    HEXSYM                  ;  convert code to characters
  247.     mov     word ptr TEXT6AX,ax     ;  store return code
  248.     mov     ax,SEC                  ;
  249.     lea     bp,TEXT6SEC             ;  target for editing
  250.     Call    INTSYM                  ;  convert integer to characters
  251.     DIAM0   TEXT6,2,6,-6,0,0        ;  output a message
  252.     mov     IOFF,0                  ;
  253.     CLR     5,25,07h                ;  clear screen
  254.     jmp     Addres                  ;  repeat disk address input
  255. Str25:  mov     IOFF,offset I25         ;
  256.     DIAM1   TXT25,1,25,25,0,0       ;  output prompt
  257.     mov     IOFF,0                  ;
  258. ;----------------------------------------------------------
  259. ;  Output sector contents in the screen (rows  5---22)
  260. ;  Editing and outputting the first page (first 256 bytes)
  261. ;----------------------------------------------------------
  262. P1:     lea     si,RDBUF                ;  source
  263.     lea     bp,Disp1                ;
  264.     Call    SCREEN                  ;  output first 256 bytes
  265.     mov     BUFER+5,'1'             ;  page number
  266.     DIAM1   BUFER,3,5,22,5,39       ;  output buffer onto the screen
  267.     lea     di,RDBUF                ;  target
  268.     Call    MODSECT                 ;
  269.     cmp     MOD0,1                  ;  was address modifyied ?
  270.     jne     NEW1                    ;
  271.     jmp     Rdsect                  ;  output modified sector
  272. NEW1:   Call    NEWSEC                  ;  change sector number
  273.     cmp     MOD0,1                  ;  was address modified?
  274.     jne     Esc1                    ;
  275.     jmp     Rdsect                  ;  output modified sector
  276. ;  Processing keys: Esc, PgDn, PgUp, Enter
  277. Esc1:   cmp     byte ptr W,1bh          ;  Esc ?
  278.     je      JmpBeg                  ;
  279.     cmp     byte ptr W+1,51h        ;  PgDn ?
  280.     je      P2                      ;  output second part of sector
  281.     cmp     byte ptr W+1,49h        ;  PgUp ?
  282.     jne     P2                      ;
  283.     cmp     SEC,0                   ;  sector number 0 ?
  284.     jz      MOD1                    ;
  285.     dec     SEC                     ;  backward reading
  286. MOD1:   jmp     Rdsect                  ;  repeat reading of sector
  287. JmpBeg: jmp     Diskadr
  288. ;  Editing and outputting the second page (last 256 bytes)
  289. P2:     lea     si,RDBUF+256            ;  source
  290.     lea     bp,Disp2                ;
  291.     Call    SCREEN                  ;  output last 256 bytes
  292.     mov     BUFER+5,'2'             ;  page number
  293.     DIAM1   BUFER,3,5,22,5,39       ;  output buffer into the screen
  294.     lea     di,RDBUF+256            ;  target
  295.     Call    MODSECT                 ;  
  296.     cmp     MOD0,1                  ;  was sector modified
  297.     jne     NEW2                    ;
  298.     jmp     Rdsect                  ;  output modified sector
  299. NEW2:   Call    NEWSEC                  ;  
  300.     cmp     MOD0,1                  ;  was address modified
  301.     jne     Esc2                    ;
  302.     jmp     Rdsect                  ;  output modified sector
  303. ;  Processing keys: Esc, PgDn, PgUp, Enter
  304. Esc2:   cmp     byte ptr W,1bh          ;  ESC key?
  305.     je      JmpBeg                  ;  return to the beginning
  306.     cmp     byte ptr W+1,49h        ;  PgUp ?
  307.     jne     PgDn2                   ;
  308.     jmp     P1                      ;
  309. PgDn2:  cmp     byte ptr W+1,51h        ;  PgDn ?
  310.     je      Next2                   ;
  311.     jmp     P2                      ;
  312. Next2:  inc     SEC                     ;
  313.     jmp     Rdsect                  ;  process next sector
  314. ;----------------------------------------------------------
  315. ;  Complete work of the procedure
  316. Exit:    mov    ah,0                    ;  set display mode
  317.      mov    al,REG                  ;  display mode been saved
  318.      int    10h                     ;  restore display mode
  319.      mov    ah,0Eh                  ;  set disk drive
  320.      mov    dl,DISK0                ;  current disk drive
  321.      int    21h                     ;  restore current disk drive
  322.      mov    ax,4c00h                ;  normal end of the program
  323.      int    21h                     ;  return to MS-DOS
  324.  
  325. ;----------------------------------------------------------
  326. ;
  327. ;  Reading sector (512 bytes) at given address
  328. ;
  329. ;----------------------------------------------------------
  330. SECTOR  PROC    NEAR
  331.     mov     ax,VER                  ;  AL - version, AH - subversion
  332.     cmp     al,4                    ;  DOS 4.0  and higher?
  333.     jnl     NEWDOS                  ;
  334. ;  Read a sector of disk less than 32M
  335. OLDDOS: mov     al,Disk                 ;  logical device number
  336.     lea     bx,RDBUF                ;  reading buffer address:  DS:BX
  337.     mov     cx,1                    ;  number of sectors to read (upto 8)
  338.     mov     dx,SEC                  ;  sector number
  339.     int     25h                     ;  read sector
  340.     pop     cx                      ;  stack alignment
  341.     RET                             ;
  342. ;  Read a sector of disk greater than 32M
  343. NEWDOS: mov     al,Disk                 ;  logical device number
  344.     lea     bx,TRPACK               ;  address of info buffer
  345.     mov     cx,0FFFFh
  346.     mov     dx,SEC                  ;  sector number (0 ...)
  347.     mov     word ptr SECNUM,dx
  348.     int     25h                     ;  read sector
  349.     pop     cx                      ;  stack alignment
  350.     RET                             ;
  351. SECTOR  ENDP
  352.  
  353. ;----------------------------------------------------------
  354. ;
  355. ;  Reading sector (512 bytes) at given address
  356. ;
  357. ;----------------------------------------------------------
  358. WRSECT  PROC    NEAR
  359.     mov     ax,VER                  ;  AL - version, AH - subversion
  360.     cmp     al,4                    ;  DOS 4.0  and higher?
  361.     jnl     GT32MB                  ;
  362. ;  Write a sector of disk less than 32M
  363.     mov     al,Disk                 ;  logical device number
  364.     lea     bx,RDBUF                ;  address of reading buffer:  DS:BX
  365.     mov     cx,1                    ;  number of sectors
  366.     mov     dx,SEC                  ;  sector number
  367.     int     26h                     ;  write sector
  368.     pop     cx                      ;  stack alignmrnt
  369.     RET                             ;
  370. ;  Write a sector of disk greater than 32M
  371. GT32MB: mov     al,Disk                 ;  logical device number
  372.     lea     bx,TRPACK               ;  address of info buffer
  373.     mov     cx,0FFFFh
  374.     mov     dx,SEC                  ;  sector number (0 ...)
  375.     mov     word ptr SECNUM,dx
  376.     int     26h                     ;  write sector
  377.     pop     cx                      ;  stack alignment
  378.     RET                             ;
  379. WRSECT  ENDP
  380.  
  381. ;----------------------------------------------------------
  382. ;
  383. ;  Procedure for display buffer forming (256 bytes)
  384. ;
  385. ;  SI  -address of source buffer of the sector been read
  386. ;
  387. ;  BP  -Displacement table address
  388. ;
  389. ;----------------------------------------------------------
  390. SCREEN   PROC   NEAR
  391.      PUSHR                          ;  save all registers
  392.      PUSHR  <si,bp>                 ;
  393.      SPACE  BUFER,2000              ;  clear screen buffer
  394.      lea    si,TEXT5                ;  source
  395.      lea    di,BUFER+27             ;  target
  396.      mov    cx,Ltext5               ;  length
  397.      Call   MOVE                    ;  send row of addresses
  398.      mov    ax,SEC                  ;  sector address
  399.      lea    bp,BUFER+38             ;  target for editing
  400.      Call   INTSYM                  ;  convert integer to characters
  401. ;  Form headline (row =6)
  402.      lea    si,TXT0                 ;  source
  403.      lea    di,BUFER+80             ;  target
  404.      mov    cx,80                   ;  length
  405.      Call   MOVE                    ;  send headline
  406.      POPR   <bp,si>                 ;
  407.      lea    di,BUFER+160            ;  address of screen beginning
  408.      mov    ADRBUF,di               ;  save address of row beginning
  409.      mov    dx,16                   ;  nomber of row on screen
  410. ;  Outward loop on 16 rows of information
  411. S0:      PUSHR  <si,di>                 ;
  412.      inc    di                      ;  target
  413.      mov    si,bp                   ;  source
  414.      mov    cx,10                   ;  length
  415.      Call   MOVE                    ;  send marking
  416.      POPR   <di,si>                 ;
  417.      mov    cx,16                   ;  number of characters in row
  418.      mov    bx,di                   ;  save address of row beginning
  419. ;  Inner loop on 16  characters in a row
  420. S1:      mov    al,[si]                 ;  start of inner loop
  421.      Call   HEXSYM                  ;  converting HEX ---> SYM
  422.      mov    DS:[di+13],ax           ;  pass hexadecimal value
  423.      mov    al,[si]                 ;  ASCII character
  424.      cmp    al,1bh                  ;  Esc ?
  425.      ja     S2                      ;  if not, pass without processing
  426.      mov    al,20h                  ;  else replace with blank
  427. S2:      mov    [bx+63],al              ;  pass  ASCII  character
  428.      add    di,3                    ;  address of next two bytes
  429.      inc    bx                      ;  address of next ASCII  character
  430.      inc    si                      ;  address of next byte in sector
  431.      loop   S1                      ;  next step of inner loop
  432. ;  Modify parameters of outward loop (pass to next row)
  433.      mov    di,ADRBUF               ;
  434.      add    di,80                   ;  address of next row
  435.      mov    ADRBUF,di               ;  save address of start of row
  436.      add    bp,10                   ;  address of next element
  437.      dec    dx                      ;  number of rows remained
  438.      jnz    S0                      ;  next step of outward loop
  439. ; Pass transformed addresses to  TEXT5 string
  440.      lea    si,BUFER+27             ;  source
  441.      lea    di,TEXT5                ;  target
  442.      mov    cx,Ltext5               ;  length
  443.      Call   MOVE                    ;  send string of addresses
  444.      POPR                           ;
  445.      RET                            ;
  446. SCREEN   ENDP
  447.  
  448. ;----------------------------------------------------------
  449. ;
  450. ;  The modification of a data sector
  451. ;
  452. ;  Is performed when the cursor is in the data area 
  453. ;
  454. ;  and the ENTER key is pressed
  455. ;
  456. ;  DS:DI - the address of the buffer in data segment
  457. ;
  458. ;----------------------------------------------------------
  459. MODSECT PROC    NEAR
  460.     mov     MOD0,0                  ;  clear modification indicator
  461.     cmp     byte ptr W,0Dh          ;  is ENTER pressed?
  462.     jne     RetModS                 ;  if not, exit
  463.     cmp     byte ptr Q,7            ;  is cursor within data area?
  464.     jl      RetModS                 ;  if not, exit
  465.     cmp     byte ptr Q,22           ;  is cursor within data area?
  466.     jg      RetModS                 ;  if not, exit
  467.     cmp     byte ptr S,14           ;  is cursor within data area?
  468.     jl      RetModS                 ;  if not, exit
  469.     cmp     byte ptr S,72           ;  is cursor within data area?
  470.     jng     C0                      ;  YES
  471. RetModS:RETN                            ;  if not, exit
  472. ;  Modification the sector buffer accordingly to the screen modified
  473. ;  (lines 7---22)
  474. C0:     PUSHR                           ;
  475.     mov     MOD0,1                  ;  modification indicator
  476.     mov     ax,ds                   ;
  477.     mov     es,ax                   ;  ES points to data segment
  478.     lea     si,BUFER+173            ;  address of screen beginning
  479.     mov     ADRBUF,si               ;  store address of string beginning
  480.     mov     dx,16                   ;  number of lines on screen
  481. ; Process 16 lines
  482. C1:     mov     cx,16                   ;  number of characters in line
  483. C2:     mov     ax,[si]                 ;  start nested cycle
  484.     Call    SYMHEX                  ;  convert characters to HEX
  485.     mov     [di],al                 ;  store HEX value
  486.     add     si,3                    ;  take next two bytes
  487.     inc     di                      ;  next byte of sector
  488.     loop    C2                      ;  next step of nested cycle
  489. ;  Process the next line (the outward cycle)
  490.     mov     si,ADRBUF               ;
  491.     add     si,80                   ;  address of next line
  492.     mov     ADRBUF,si               ;  store address of line's beginning
  493.     dec     dx                      ;  number of rest lines
  494.     jnz     C1                      ;  next step of outward cycle
  495.     mov     ax,ds                   ;
  496.     mov     es,ax                   ;  ES points to data segment
  497.     Call    WRSECT                  ;  write sector
  498.     jc      ErrWr                   ;  if not successful - output message
  499.     POPR                            ;
  500.     RETN                            ;
  501. ;  Output an error message
  502. ErrWr:  Call    HEXSYM                  ;  convert code to characters
  503.     mov     word ptr TEXT8AX,ax     ;  store error code for output
  504.     mov     ax,SEC                  ;
  505.     lea     bp,TEXT8SEC             ;  target for editing
  506.     Call    INTSYM                  ;  convert integer to character
  507.     DIAM0   TEXT8,2,6,-6,0,0        ;  output message
  508.     mov     IOFF,0                  ;
  509.     CLR     5,25,07h                ;  clear screen
  510.     POPR                            ;
  511.     RETN                            ;
  512. MODSECT ENDP
  513.  
  514. ;----------------------------------------------------------
  515. ;
  516. ;   Procedure for processing address of sector given in string
  517. ;
  518. ;----------------------------------------------------------
  519. NEWSEC   PROC   NEAR
  520.      mov    MOD0,0                  ;  clear modification indicator
  521.      lea    bp,BUFER+38             ;  sector number
  522.      mov    si,5                    ;  source characters counter
  523.      Call   SYMIN4                  ;  convert characters to integer
  524.      cmp    SEC,ax                  ;  sector number modified?
  525.      mov    SEC,ax                  ;  store new sector number
  526.      je     Retmod                  ;
  527.      mov    MOD0,1                  ;  set modification indicator
  528. Retmod:  RET
  529. NEWSEC   ENDP
  530.  
  531. ;----------------------------------------------------------
  532. ;
  533. ;  The subroutine for converting an integer number into character string
  534. ;
  535. ;  AX  - the number to be converted
  536. ;
  537. ;  BP  - target addres of character string
  538. ;
  539. ;
  540. ;
  541. ;----------------------------------------------------------
  542. INTSYM  PROC    NEAR
  543.     xor     dx,dx                   ;  make high part zero
  544.     mov     si,5                    ;  number of characters edited
  545.     Call    INSYM4                  ;  place leading zero
  546.     cmp     byte ptr DS:[bp],' '    ;  suppressed zero?
  547.     ja      ZER2                    ;
  548.     mov     byte ptr DS:[bp],'0'    ;  place leading zero
  549. ZER2:   cmp     byte ptr DS:[bp]+1,' '  ;  suppressed zero?
  550.     ja      ZER3                    ;
  551.     mov     byte ptr DS:[bp]+1,'0'  ;  place leading zero
  552. ZER3:   cmp     byte ptr DS:[bp]+2,' '  ;  suppressed zero?
  553.     ja      ZER4                    ;
  554.     mov     byte ptr DS:[bp]+2,'0'  ;  place leading zero
  555. ZER4:   cmp     byte ptr DS:[bp]+3,' '  ;  suppressed zero?
  556.     ja      Retint                  ;
  557.     mov     byte ptr DS:[bp]+3,'0'  ;  place leading zero
  558. Retint: RET
  559. INTSYM  ENDP
  560. CODE     ENDS
  561.      END    Start
  562.